<?php
define('ZHMVC_VERSION', '2.0.0 Alpha');
define('ZH', '.php');
define('LOG', '.log');
define('DS', DIRECTORY_SEPARATOR);
define('ZH_PATH',dirname(dirname(__FILE__)));//定义系统目录
define('ISZHMVCBUG',true);//定义是否调试
define('SIGNATURENEW','hbcheng');

header('Access-Control-Allow-Origin:*');

if(ISZHMVCBUG==true)
{
    error_reporting(E_ALL);
    ini_set('display_errors', '1');
}
else
{
    error_reporting(0);//E_ALL 0
    ini_set('display_errors', '0');//1 0
}
include_once(ZH_PATH.DS."common".DS."tool".DS."Fun".ZH);
include_once(ZH_PATH.DS."common".DS."ZhLoader".ZH);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>安装程序</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
</head>
<body>
<div class="top">
	<div class="top-logo">
	</div>
	<div class="top-link">
		<ul>
			<li><a href="#" target="_blank">官方网站</a></li>
			<li><a href="#" target="_blank">技术论坛</a></li>
			<li><a href="#" target="_blank">帮助</a></li>
		</ul>
	</div>
	<div class="top-version">
		<!-- 版本信息 -->
		<h2>YIGECMS安装</h2>
	</div>
</div>
<div class="main">
	<div class="pleft">
		<dl class="setpbox t1">
			<dt>安装步骤</dt>
			<dd>
				<ul>
					<li class="succeed">许可协议</li>
					<li class="succeed">环境检测</li>
					<li class="succeed">参数配置</li>
					<li class="now">正在安装</li>
					<li>安装完成</li>
				</ul>
			</dd>
		</dl>
	</div>
    <div class="pright">
  <!--右边-->
  <form action="" method="get">
  <div class="index_mian_right_one_ly">
  <div class="index_mian_right_one_one_ly"><span>正在配置数据库链接</span></div>
  <div class="font">
  <?php   
  $adminuser=SafeRequest(getPGC("adminuser"),0);
  $adminpass=SafeRequest(getPGC("adminpass"),0);
  $yuming=SafeRequest(getPGC("yuming"),0);
  $webname=SafeRequest(getPGC("webname"),0);
  $managerpath=SafeRequest(getPGC("managerpath"),0);

  $conn=new \ZHMVC\D\DataBase();
  $sql="
CREATE TABLE `zhmvc_admin_menu`  (
  `id` char(20)  NOT NULL,
  `pid` char(20)  NULL DEFAULT NULL,
  `menuname` varchar(250)  NULL DEFAULT NULL,
  `title` varchar(250)  NULL DEFAULT NULL,
  `url` varchar(250)  NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
)";
  $conn->SqlUpdate($sql);
  
  $sql="
INSERT INTO `zhmvc_admin_menu` VALUES ('1734646894002438144', '0', 'system_', '系统管理', '/".$managerpath."/admin_config.php');";
  $conn->SqlUpdate($sql);
  $sql="
INSERT INTO `zhmvc_admin_menu` VALUES ('1734647004417490944', '1734646894002438144', 'system_', '系统设置', '/".$managerpath."/admin_config.php');";
  $conn->SqlUpdate($sql);
  $sql="
INSERT INTO `zhmvc_admin_menu` VALUES ('1734647074177155072', '1734646894002438144', 'system_', '管理员管理', '/".$managerpath."/admin_master.php');";
  $conn->SqlUpdate($sql);
  $sql="
INSERT INTO `zhmvc_admin_menu` VALUES ('1735376675232808960', '1734646894002438144', 'system_', '模块管理', '/".$managerpath."/admin_module.php');";
  $conn->SqlUpdate($sql);
  $sql="
INSERT INTO `zhmvc_admin_menu` VALUES ('1735376830044569600', '1734646894002438144', 'system_', '自定义变量管理', '/".$managerpath."/admin_label.php');";
  $conn->SqlUpdate($sql);
  $sql="
INSERT INTO `zhmvc_admin_menu` VALUES ('1735790720247136256', '1734646894002438144', 'system_', '登录日志', '/".$managerpath."/admin_loginlog.php');";
  $conn->SqlUpdate($sql);
  $sql="
INSERT INTO `zhmvc_admin_menu` VALUES ('1824741834727882752', '1734646894002438144', 'system_', '公共标签', '/".$managerpath."/admin_template_sql_comm.php');";
  $conn->SqlUpdate($sql);
  $sql="
INSERT INTO `zhmvc_admin_menu` VALUES ('1824742649886670848', '1734646894002438144', 'system_', '前端导航类型', '/".$managerpath."/admin_menutype.php');";
  $conn->SqlUpdate($sql);
  $sql="
INSERT INTO `zhmvc_admin_menu` VALUES ('1842906277194235904', '1734646894002438144', 'system_', '数据库备份恢复', '/".$managerpath."/admin_mysql.php');";
  $conn->SqlUpdate($sql);
  $sql="
INSERT INTO `zhmvc_admin_menu` VALUES ('1842906277655609344', '1734646894002438144', 'system_', '表单字段管理', '/".$managerpath."/admin_options.php');";
  $conn->SqlUpdate($sql);
  $sql="
INSERT INTO `zhmvc_admin_menu` VALUES ('1842906277898878976', '1734646894002438144', 'system_', '表单分类管理', '/".$managerpath."/admin_optionsclass.php');";
  $conn->SqlUpdate($sql);
  
  $sql="
CREATE TABLE `zhmvc_config`  (
  `name` varchar(255)  NULL DEFAULT NULL COMMENT '键名称',
  `value` varchar(255)  NULL DEFAULT NULL COMMENT '键值',
  `description` tinytext  NULL COMMENT '键描述'
);";
  $conn->SqlUpdate($sql);
  
  $sql="
INSERT INTO `zhmvc_config` VALUES ('SiteName', '".$webname."', NULL);
  ";
  $conn->SqlUpdate($sql);
  $sql="
INSERT INTO `zhmvc_config` VALUES ('SiteUrl', 'http://".$yuming."', NULL);
  ";
  $conn->SqlUpdate($sql);
  
  
  $sql="
CREATE TABLE `zhmvc_frontmenu`  (
  `id` char(20)  NOT NULL COMMENT 'id',
  `fid` char(20)  NULL DEFAULT '0' COMMENT '父id',
  `name` varchar(250)  NULL DEFAULT NULL COMMENT '菜单名称',
  `subname` varchar(255)  NULL DEFAULT NULL COMMENT '子名称',
  `ismenu` enum('否','是')  NULL DEFAULT '是' COMMENT '是否显示',
  `ordernum` int(4) NULL DEFAULT 0 COMMENT '排序',
  `phpfile` varchar(255)  NULL DEFAULT NULL COMMENT '执行文件',
  `info` text  NULL COMMENT '介绍',
  `datu` varchar(255)  NULL DEFAULT NULL COMMENT '大图标',
  `tubiao` varchar(255)  NULL DEFAULT NULL COMMENT '图标',
  `moduleid` char(20)  NULL DEFAULT NULL COMMENT '模块id',
  `aid` char(20)  NULL DEFAULT NULL COMMENT '栏目id',
  `htmlfile` varchar(255)  NULL DEFAULT NULL COMMENT '模板文件',
  PRIMARY KEY (`id`) USING BTREE
);";
  $conn->SqlUpdate($sql);
  
  $sql="
INSERT INTO `zhmvc_frontmenu` VALUES ('1842906277898878976', '', '', '首页', 'HOME', '1', 1, '/index.php', '".$webname."', '', '', '', '', '', '', '');";
  $conn->SqlUpdate($sql);
  
  $sql="
CREATE TABLE `zhmvc_label`  (
  `id` char(20)  NOT NULL,
  `name` varchar(255)  NULL DEFAULT NULL,
  `value` longtext  NULL,
  `type` varchar(255)  NULL DEFAULT NULL,
  `dec` text  NULL,
  `addtime` datetime NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
)  ;";
  $conn->SqlUpdate($sql);
  
  
  $sql="
CREATE TABLE `zhmvc_loginlog`  (
  `id` char(20)  NOT NULL,
  `username` varchar(255)  NULL DEFAULT NULL,
  `password` varchar(255)  NULL DEFAULT NULL,
  `loginip` varchar(255)  NULL DEFAULT NULL,
  `result` varchar(255)  NULL DEFAULT NULL,
  `addtime` datetime NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
)";
  $conn->SqlUpdate($sql);
  
  $sql="
CREATE TABLE `zhmvc_master`  (
  `id` char(20)  NOT NULL,
  `username` varchar(20)  NULL DEFAULT NULL,
  `userpassword` varchar(32)  NULL DEFAULT NULL,
  `column_setting` longtext  NULL,
  `seting` longtext  NULL,
  `lastime` datetime NULL DEFAULT NULL,
  `lastip` varchar(15)  NULL DEFAULT NULL,
  `cookiess` varchar(10)  NULL DEFAULT NULL,
  `state` enum('1','0')  NULL DEFAULT '1',
  `openid` varchar(255)  NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
);";
  $conn->SqlUpdate($sql);
  
  $sql="INSERT INTO `zhmvc_master` VALUES ('1734646461766828032', 'admin', 'e10adc3949ba59abbe56e057f20f883e', '11,12,13,14,121,122,123,124,141,142,143,144,151,152,153,154,131,132,133,134,111,112,113,114,161,162,163,164,171,172,173,174,191,192,193,194,221,222,223,224,231,232,233,234,181,182,183,184,201,202,203,204,211,212,213,214,251,252,253,254,261,262,263,264,', 'system_/".$managerpath."/admin_config.php,system_/".$managerpath."/admin_master.php,system_/".$managerpath."/admin_module.php,system_/".$managerpath."/admin_label.php,system_/".$managerpath."/admin_loginlog.php,system_/".$managerpath."/admin_template_sql_comm.php,system_/".$managerpath."/admin_menutype.php,system_/".$managerpath."/admin_mysql.php,system_/".$managerpath."/admin_options.php,system_/ygmanager/admin_optionsclass.php,', NULL, '', '', '1', '')";
  $conn->SqlUpdate($sql);
 
  
  $sql="
CREATE TABLE `zhmvc_models`  (
  `id` int(6) NOT NULL AUTO_INCREMENT,
  `domainkey` varchar(255)  NULL DEFAULT '',
  `name` varchar(20)  NULL,
  `displayorder` tinyint(3) NULL DEFAULT 0,
  `type` tinyint(1) NULL DEFAULT 0,
  `options` mediumtext  NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `domainkey`(`domainkey`) USING BTREE
)  ;
";
  $conn->SqlUpdate($sql);
  
  
  $sql="
CREATE TABLE `zhmvc_module`  (
  `id` char(20)  NOT NULL,
  `biaoqianzhui` varchar(250)  NULL DEFAULT NULL COMMENT '数据表前缀',
  `mulu` varchar(250)  NULL DEFAULT NULL COMMENT '目录',
  `name` varchar(250)  NULL DEFAULT NULL COMMENT '插件名称',
  `modulename` varchar(255)  NULL DEFAULT NULL COMMENT '必须不能相同，唯一的自己设定的标识',
  `modulenamespace` varchar(255)  NULL DEFAULT NULL COMMENT '命名空间',
  `rpcmainkey` char(32)  NULL DEFAULT '本地' COMMENT '如果是远程的话，唯一标识的key',
  `rpctype` enum('远程','本地')  NULL DEFAULT '本地' COMMENT 's数据的类型，是本地数据还是远程数据',
  `rpcurl` varchar(255)  NULL DEFAULT NULL COMMENT '远程地址',
  `rpchost` varchar(255)  NULL DEFAULT NULL,
  `rpcprivatekey` varchar(255)  NULL DEFAULT NULL,
  `rpcmoduleid` char(20)  NULL DEFAULT NULL,
  `version` char(20)  NULL DEFAULT NULL COMMENT '版本号',
  PRIMARY KEY (`id`) USING BTREE
) 
";
  $conn->SqlUpdate($sql);
  
  $sql="
CREATE TABLE `zhmvc_moduletable`  (
  `id` char(20)  NOT NULL,
  `moduleid` char(20)  DEFAULT NULL,
  `classname` varchar(255)  DEFAULT NULL,
  `info` varchar(255)  DEFAULT NULL,
  `mtype` enum('list','column','diy')  DEFAULT 'list',
  PRIMARY KEY (`id`) USING BTREE
)
";
  $conn->SqlUpdate($sql);
  
  $sql="
CREATE TABLE `zhmvc_mysql`  (
  `id` char(20)  NOT NULL,
  `name` varchar(255)  NULL DEFAULT NULL,
  `addtime` datetime NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
)
";
  $conn->SqlUpdate($sql);
  
  $sql="
CREATE TABLE `zhmvc_options`  (
  `id` char(20)  NOT NULL,
  `classid` char(20)  NULL DEFAULT '0',
  `title` varchar(250)  NULL DEFAULT '',
  `description` varchar(255)  NULL DEFAULT '',
  `type` varchar(20)  NULL DEFAULT '',
  `rules` text  NULL,
  `formkey` varchar(255)  NULL DEFAULT NULL,
  `formvalue` text  NULL,
  `otherkey` varchar(255) NULL DEFAULT NULL,
  `paixu` int(6) NULL DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `classid`(`classid`) USING BTREE,
  INDEX `paixu`(`paixu`) USING BTREE
)
";
  $conn->SqlUpdate($sql);
  
  $sql="
CREATE TABLE `zhmvc_optionsclass`  (
  `id` char(20)  NOT NULL,
  `title` varchar(255)  NULL DEFAULT NULL,
  `description` varchar(255)  NULL DEFAULT NULL,
  `bgcolor` varchar(255)  NULL DEFAULT NULL,
  `isok` enum('1','0')  NULL DEFAULT '1',
  `paixu` int(6) NOT NULL DEFAULT 0,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `paixu`(`paixu`) USING BTREE
);
";
  $conn->SqlUpdate($sql);
  
 
  $sql="
CREATE TABLE `zhmvc_optionvalue`  (
  `id` char(20)  NOT NULL COMMENT 'id',
  `classid` varchar(250)  DEFAULT '0' COMMENT '',
  `aid` char(20)  DEFAULT NULL COMMENT 'id',
  `title` varchar(255)  DEFAULT NULL,
  `description` varchar(255)  DEFAULT NULL,
  `name` varchar(255)  DEFAULT NULL COMMENT '键名',
  `info` text  COMMENT '键值',
  INDEX `name`(`name`) USING BTREE,
  INDEX `id`(`id`) USING BTREE,
  INDEX `classid`(`classid`) USING BTREE,
  INDEX `aid`(`aid`) USING BTREE
);
";
  $conn->SqlUpdate($sql);
  
  $sql="
CREATE TABLE `zhmvc_templatetag`  (
  `id` char(20)  NOT NULL COMMENT 'id',
  `parameter` varchar(255)  NULL DEFAULT NULL COMMENT '前端标签名称',
  `isql` text  NULL COMMENT 'sql语句',
  `tiaoshu` int(11) NULL DEFAULT 1 COMMENT '显示条数',
  `orderby` varchar(30)  NULL DEFAULT NULL COMMENT '排序方式',
  `columnid` char(20)  NULL DEFAULT NULL COMMENT '类别编号',
  `isimg` enum('是','否')  NULL DEFAULT '是' COMMENT '包含图片',
  `ispage` enum('是','否')  NULL DEFAULT '是' COMMENT '是否分页',
  `isfid` enum('是','否')  NULL DEFAULT '是' COMMENT '包含下级',
  `aid` char(20)  NULL DEFAULT NULL COMMENT '内容编号',
  `paixu` int(11) NULL DEFAULT NULL COMMENT '排序',
  PRIMARY KEY (`id`) USING BTREE
)
";
  $conn->SqlUpdate($sql);
  
  $sql="
CREATE TABLE `zhmvc_yctable`  (
  `id` char(20)  NOT NULL,
  `datatable` varchar(50)  NULL DEFAULT NULL,
  `liename` varchar(50)  NULL DEFAULT NULL,
  `colindex` varchar(10)  NULL DEFAULT NULL,
  `lietagname` varchar(50)  NULL DEFAULT NULL,
  `isshow` enum('1','0')  NULL DEFAULT '1',
  `xuhao` smallint(5) UNSIGNED NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
);
";
  $conn->SqlUpdate($sql);

  echo "系统表安装成功<br>";
  
  ?>
   数据库安装成功！</div>
   <div class="btn">
   	<script>
    window.location.href='instal__from.php?managerpath=<?php echo $managerpath;?>';
    </script>
   </div>
   
  </div>
  <!--进入系统-->
</div>
</body>
</html>

